package com.cskaoyan.proxy;

import com.cskaoyan.service.UserService;
import com.cskaoyan.util.ProxyUtil;
import lombok.Data;
import org.springframework.beans.factory.FactoryBean;

/**
 * 补全代码，通过该类能够提供一个service的代理组件，并且从单元测试类中取出该组件能够实现事务
 * @author stone
 */
@Data
public class ServiceProxyFactoryBean implements FactoryBean<UserService> {

    UserService userService;

    @Override
    public UserService getObject() throws Exception {
        //获得一个代理对象
        //return ProxyUtil.getServiceProxy(userService.getClass());
        return ProxyUtil.getServiceProxy(userService);
    }

    @Override
    public Class<?> getObjectType() {
        return UserService.class;
    }
}
